package org.atlantis.netty.decoder;

import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelStateEvent;
import org.jboss.netty.channel.ChildChannelStateEvent;
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;

/**
 * ServerSocketChannel的childChannel不是指客户端的Channel。
 * 客户端channel的状态还是使用channelConnected等方法监听， 目前还使用不到childChannel。
 * 
 * @author xi_li
 * 
 */
public class StateListenerHandler extends SimpleChannelUpstreamHandler {

	@Override
	public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
		System.out.println("A remote client<" + e.getChannel().getRemoteAddress() + "> connected.");
	}

	@Override
	public void childChannelOpen(ChannelHandlerContext ctx, ChildChannelStateEvent e) throws Exception {
		System.out.println("A remote client<" + e.getChannel().getRemoteAddress() + "> connected.");
	}

	@Override
	public void childChannelClosed(ChannelHandlerContext ctx, ChildChannelStateEvent e) throws Exception {
		System.out.println("A remote client<" + e.getChannel().getRemoteAddress() + "> disconnected.");
	}
}
